import { FromOptionsProp } from "../interface";

export const useOther = () => {
  // 验证表单类型
  const verifyItemType = (item: FromOptionsProp, type: FromOptionsProp["type"]) => type === item.type;

  // 验证表单类型
  const inputStyle: any = {
    disableColor: "#fff"
  };
  // 设置占位符
  const setPlaceholder = (item: FromOptionsProp, type: FromOptionsProp["type"]) => {
    const { label, attrs } = item || {};
    if (attrs?.placeholder) return attrs.placeholder;

    const { SKIP, SELECT, DATE, SELECT_CUSTOM } = FORM_FLAG;
    const selectFlag: any = [SKIP, SELECT, DATE, SELECT_CUSTOM];
    return (selectFlag.includes(type) ? `请选择` : `请输入`) + label;
  };

  return {
    inputStyle,
    verifyItemType,
    setPlaceholder
  };
};
